aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(app)/redeem/[redeemcode]/+page.server.js
blob: f227f22e03d54c8206029c400bdc8a8790010e24 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import { error, redirect } from "@sveltejs/kit";
import { auth, post } from "$lib/utils";

export async function load({ cookies, locals, params }) {
  let { user } = locals;

  if (user) {
    try {
      await post("/redeem", params, auth(cookies));
    } catch (e) {
      throw redirect(307, "/");
    }
    throw redirect(307, `/${user.username}/payments`);
  }

  throw redirect(307, "/login");
}